<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Mged User's Manual</title>
  <style type="text/css">
  body {
  background-color: #E0D8C8;
  color: #000000;
  }
  pre.c3 {font-size: 64%}
  span.c2 {color: #20A020}
  div.c1 {text-align: center}
  </style>
</head>
<body>
  <h2><a name="csg" id="csg">Modeling With CSG</a></h2>In BRL-CAD
  objects are constructed using a technique known as
  ``Combinatorial Solid Geometry'' or ``Constructive Solid
  Geometry'' or simply ``CSG'' In the CSG approach to modeling This
  technique involves creating objects by combining primitive shapes
  together to form complex objects.&nbsp; The primitive shapes are
  called ``solids''.&nbsp; Each one occupies a volume of three
  dimensional space.&nbsp; BRL-CAD currently has many primitive
  solid types.&nbsp; These include:
  <div class="c1">
    * = Implementation known to be incomplete as of this writing
    <table border>
      <tr>
        <th>Primitive Shape</th>
        <th>BRL-CAD Name</th>
      </tr>
      <tr>
        <td>Arbitrary Convex Polyhedron</td>
        <td>arbn</td>
      </tr>
      <tr>
        <td>Arbitrary Convex Polyhedron (8pt or less)</td>
        <td>arb</td>
      </tr>
      <tr>
        <td>Extruded Bitmap *</td>
        <td>ebm *</td>
      </tr>
      <tr>
        <td>Elliptical Hyperboloid</td>
        <td>ehy</td>
      </tr>
      <tr>
        <td>Ellipsoid</td>
        <td>ell</td>
      </tr>
      <tr>
        <td>Elliptical Paraboloid</td>
        <td>epa</td>
      </tr>
      <tr>
        <td>Elliptical Torus</td>
        <td>eto</td>
      </tr>
      <tr>
        <td>Halfspace</td>
        <td>half</td>
      </tr>
      <tr>
        <td>Height-Field *</td>
        <td>hf *</td>
      </tr>
      <tr>
        <td>N-Manifold Geometry *</td>
        <td>nmg *</td>
      </tr>
      <tr>
        <td>Non-Uniform Rational B-spline *</td>
        <td>nurb *</td>
      </tr>
      <tr>
        <td>particle *</td>
        <td>part *</td>
      </tr>
      <tr>
        <td>polygonal object</td>
        <td>polygon</td>
      </tr>
      <tr>
        <td>pipe *</td>
        <td>pipe *</td>
      </tr>
      <tr>
        <td>Right Elliptical Cylinder</td>
        <td>rec</td>
      </tr>
      <tr>
        <td>Right Hyperbolic Cylinder</td>
        <td>rhc</td>
      </tr>
      <tr>
        <td>Right Parabolic Cylinder</td>
        <td>rpc</td>
      </tr>
      <tr>
        <td>Sphere</td>
        <td>sph</td>
      </tr>
      <tr>
        <td>Truncated General Cone</td>
        <td>tgc</td>
      </tr>
      <tr>
        <td>Torus</td>
        <td>tor</td>
      </tr>
      <tr>
        <td>Volume/Voxel *</td>
        <td>vol *</td>
      </tr>
    </table>
  </div>
  <div class="c1"><img src="prims.gif" alt=
  "primitive solids"></div>
  <p>These primitives can be combined using boolean operators to
  create complex shapes.&nbsp; The three boolean operations
  supported are union, difference (or subtraction), and
  intersection.&nbsp; Any number of primitives may be combined to
  produce a shape.&nbsp; The union (u) of two solids is defined as
  the volume in either of the solids.&nbsp; The difference (-) of
  two solids is the volume of the first solid which is not in the
  volume of the second solid.&nbsp; The intersection (+) of two
  solids is the volume that is contained in both solids.&nbsp;</p>
  <div class="c1"><img src="bool.gif" alt=
  "boolean operations"></div>
  <p>The result of performing a set of boolean operations is a new
  shape.&nbsp; In BRL-CAD this new shape is known as a ``<a href=
  "brlcad_glossary.html#COMBINATION">combination</a>''.&nbsp; This
  is frequently abbreviated as ``comb''.&nbsp; A ``comb'' can be
  further combined with other shapes to create still more complex
  shapes.&nbsp; For example, the shape of a simple cup might be
  created by subtracting a cylinder from a slightly larger
  cylinder.&nbsp; From this ``comb'' shape, the shape of a mug
  could be created by adding a handle.&nbsp; The handle might be
  composed of an elliptical torus with the part of the torus that
  would be inside the cup removed.&nbsp; Logically this is:</p>
  <p><a name="cup.sh" id="cup.sh"></a></p>
  <div class="c1">
    Cup = Outside - Inside<br>
    <br>
    Handle = Ring - Outside<br>
    <br>
    Mug = Cup <i>union</i> Handle
  </div>
  <div class="c1">
    <a href="cup_and_mug.gif"><img src="cup_and_mug_small.gif" alt=
    "cup and mug"></a>
  </div>
  <p>In this way the shape of objects are built up from
  components.&nbsp;</p>
  <p>When the desired shape of an object is attained, a special
  combination called a ``<a href=
  "brlcad_glossary.html#REGION">region</a>'' is created.&nbsp; A
  ``<a href="brlcad_glossary.html#REGION">region</a>'' represents
  an actual material component of the model.&nbsp; It represents an
  item which is made from a homogeneous type of material.&nbsp; In
  the example above two combinations are created: Cup and
  Handle.&nbsp; These two are brought together to form an object
  (Mug) which is made of a single material (such as ceramic or bone
  china).&nbsp; Material properties such as color, texture,
  transparency, reflectivity, etc. are assigned to regions.</p>
  <p>The model is built up as a tree-like structure known as a
  <i><a href="brlcad_glossary.html#DAG">Directed Acyclic
  Graph</a></i> or <i>DAG</i>.&nbsp; It is permissible for a node
  to be referenced by different parts of the model.&nbsp; In the
  mug example, the solid "Outside" is a part of two different
  combinations: Cup and Handle.&nbsp; In this example the graph of
  the mug object looks like this:</p>
  <pre>
                          Torus
                         /
                Handle (-)
               /         \
        Mug (u)           Cylinder
               \         /
                Cup -- (-)
                         \
                          Insides
</pre>It is possible to refer to combinations and regions multiple
times as well.&nbsp; For example, if a modeler were trying to
create a cupboard containing three separate identical mugs, he
might create a structure as follows:
  <pre>
         Mug 1                      Ring
        /     \                    /
       /       \         Handle (-)
     (u)        \       /          \
Mugs (u)- Mug 2--Mug (u)            Outside
     (u)        /       \          /
       \       /         Cup -- (-)
        \     /                    \
         Mug 3                      Inside

</pre>
  <p>Users familiar with other CAD software may prefer to think of
  the ``region'' as a ``part''.&nbsp; Combinations containing of
  ``regions'' may be thought of as ``assemblies''.&nbsp;</p>
  <h2><a name="starting" id="starting">Starting MGED</a></h2>
  <p>The program for editing BRL-CAD geometry is called
  ``mged''.</p>
  <p>All the geometry for a particular model or application is
  generally stored in a single file called a <i>database</i>.&nbsp;
  Each database may contain many different objects.&nbsp; By
  convention, the files containing BRL-CAD geometry have an
  extension of ``.g''.&nbsp;</p>
  <p>Before starting mged the user should assure that the X-Windows
  <b>DISPLAY</b> environment variable has been properly set.&nbsp;
  This indicates where applications should display the windows they
  create.&nbsp;</p>
  <p>We use the following conventions for denoting text:</p>
  <pre>
        <b><span class="c2">Text typed by the user</span></b>
        <tt>Text output by the program</tt>
</pre>To edit or create a geometry file, the user starts the mged
program from the shell by giving the command:
  <pre>
   <tt>%</tt> <b><span class="c2">mged -c cup.g</span></b>
</pre>The filename is required.&nbsp; Unlike many programs which
allow the user to create a new document or database in memory, mged
always keeps everything on disk.&nbsp; After each user command, the
contents of the disk file are brought up to date.&nbsp; By doing
this, the amount of work lost in the event of a system crash is
minimized.&nbsp;
  <p>When mged is started, it prints out the release number and
  date of compilation. When multiple versions of mged are installed
  on a machine, this allows the user to verify that the proper
  version is being started.&nbsp;</p>
  <p>If the file specified does not exist when mged is started, it
  will stop and ask if the user wishes to create a new
  database:</p>
  <pre>
   <tt>%</tt> <b><span class="c2">mged -c cup.g</span></b><tt>
   BRL-CAD Release 4.5   Graphics Editor (MGED)
       Mon May 19 16:31:32 EDT 1997, Compilation 5377
       bparker@vapor.arl.mil:/m/cad/.mged.6d

   cup.g: No such file or directory
   Create new database (y|n)[n]? </tt>
</pre>At this point pressing the ``y'' key followed by a return
will create the new database.&nbsp; Any other (non-y) keys
(followed by a return) will cause mged to quit without creating the
database.&nbsp;
  <pre>
   <tt>%</tt> <b><span class="c2">mged -c cup.g</span></b><tt>
   BRL-CAD Release 4.5   Graphics Editor (MGED)
       Mon May 19 16:31:32 EDT 1997, Compilation 5377
       bparker@vapor.arl.mil:/m/cad/.mged.6d

   cup.g: No such file or directory
   Create new database (y|n)[n]? </tt><b><span class=
"c2">y</span></b><tt>
   Creating new database "cup.g"
   Untitled MGED Database (units=mm)
   attach (nu|X|ogl|glx)[nu]? </tt>
</pre><a name="#foobar" id="#foobar">At</a> this point, mged is
asking what type of geometry display window you would like.&nbsp;
The default is always ``nu'' for Null or ``no geometry
display''.&nbsp; If you are creating geometry, it is desirable to
be able to see it.&nbsp; The common choices are:
  <div class="c1">
    <table border>
      <tr>
        <th colspan="2">MGED Geometry Display Types</th>
      </tr>
      <tr>
        <th>Name</th>
        <th>Display Type</th>
      </tr>
      <tr>
        <td align="center">X</td>
        <td>X Windows</td>
      </tr>
      <tr>
        <td align="center">glx</td>
        <td>Iris gl under X Windows</td>
      </tr>
      <tr>
        <td align="center">ogl</td>
        <td>OpenGL under X Windows</td>
      </tr>
    </table>
  </div>Enter one of the names listed followed by a return.&nbsp;
  <pre>
   <tt>%</tt> <b><span class="c2">mged -c cup.g</span></b><tt>
   BRL-CAD Release 4.5   Graphics Editor (MGED)
       Mon May 19 16:31:32 EDT 1997, Compilation 5377
       bparker@vapor.arl.mil:/m/cad/.mged.6d

   cup.g: No such file or directory
   Create new database (y|n)[n]? </tt><b><span class=
"c2">y</span></b><tt>
   Creating new database "cup.g"
   Untitled MGED Database (units=mm)
   attach (nu|X|ogl|glx)[nu]? </tt><b><span class=
"c2">ogl</span></b><tt>
   mged&gt; </tt>
</pre>At this point you should have a window that looks something
like this:
  <div class="c1">
    <a href="faceplate.gif"><img src="faceplate_sm.gif" alt=
    "faceplate"></a>
  </div><br>
  When the MGED program has a display window or device attached, it
  displays a border around the region of the screen being used
  along with some ancillary status information.&nbsp; Together,
  this information is termed the editor ``faceplate''.&nbsp;
  <p>In the upper left corner of the window is a small enclosed
  area which is used to display the current editor state. The
  current editor state indicates whether objects are selected for
  editing and what modeling operations are allowed.&nbsp;</p>
  <p>Underneath the state display is a zone in which three
  ``pop-up'' menus may appear.&nbsp; The top menu is termed the
  ``button menu,'' as it contains menu items which duplicate many
  functions which were originally available via an external
  <a href="button%20box">button box</a> peripheral.&nbsp; Having
  these frequently used functions available on a pop-up menu can
  greatly decrease the number of times that the user needs to
  remove his hand from the pointing device (either mouse or tablet
  puck) to reach for the buttons.&nbsp;</p>
  <p>Below is an example of the faceplate and first level
  menu.&nbsp;</p>
  <div class="c1">
    <a href="faceplate_menu.gif"><img src="faceplate_menu_sm.gif"
    alt="faceplate with menu"></a>
  </div>
  <p>The second menu is used primarily for the various editing
  states, at which time it contains all the editing operations
  which are generic across all objects (scaling, rotation, and
  translation).&nbsp; The third menu contains selections for
  object-specific editing operations.&nbsp; The choices on these
  menus are <a href="Edit%20Menus">detailed below</a>.&nbsp;</p>
  <p>Running across the entire bottom of the faceplate is a thin
  rectangular display area which holds two lines of text.&nbsp; The
  first line always contains a numeric display of the model-space
  coordinates of the center of the view and the current size of the
  viewing cube, both of which are displayed in the currently
  selected editing units.&nbsp; The first line also contains the
  current rotation rates.&nbsp;</p>
  <p>The second line has several uses, depending on editor
  mode.&nbsp; In various editing states this second line will
  contain certain path selection information.&nbsp; When the
  angle/distance cursor function is activated, the second line will
  be used to display the current settings of the cursor.&nbsp;</p>
  <p>All numeric interaction between the user and the editor are in
  terms of user-selected display units.&nbsp; The user may select
  from millimeters, centimeters, meters, inches, and feet, and the
  currently active display units are noted in the first display
  line.&nbsp; One important implementation detail is that all
  numeric values are stored in the database in millimeters. When
  MGED interacts with the user, it converts values from the
  database into the units selected by the user before displaying
  them.&nbsp; Likewise, values that the user enters are converted
  to millimeters before being written to the database.&nbsp;</p>
  <h2><a name="coord" id="coord">The Screen Coordinate
  System</a></h2>
  <p>Objects drawn on the screen are clipped in X, Y, and Z, to the
  size indicated on the first status line.&nbsp; This creates a
  conceptual ``viewing cube''.&nbsp; Only objects inside this cube
  are visible.&nbsp; This feature allows objects within the cube to
  be seen, without cluttering the display with objects which are
  within view in X and Y, but quite far away in the Z
  direction.&nbsp; This is especially useful when the display is
  zoomed in on a small portion of the geometry.&nbsp; On some
  displays Z axis clipping can be selectively enabled and disabled
  as a viewing aid.&nbsp;</p>
  <p>The MGED editor uses the standard right-handed screen
  coordinate system shown in the figure below.&nbsp;</p>
  <div class="c1">
    <img src="coord-axes.gif" alt="coord-axes"><br>
    <b><span class="c2">The Screen Coordinate System.</span></b>
  </div>
  <p>The Z axis is perpendicular to the screen and the positive Z
  direction is out of the screen towards the viewer.&nbsp; The
  directions of positive (+) and negative (-) axis rotations are
  also indicated.&nbsp; For these rotations, the ``Right Hand
  Rule'' applies: Point the thumb of the right hand along the
  direction of +X axis and the other fingers will describe the
  sense of positive rotation.&nbsp;</p>
  <h2><a name="create" id="create">Creating Geometry: The
  Cup</a></h2>
  <p>Let's look at the commands needed to build the <a href=
  "mged.html#cup">cup geometry</a> described in the first
  section.&nbsp; The following MGED editing session contains all
  the commands needed to create the mug.&nbsp; Each command will be
  explained below.&nbsp;</p>
  <pre>
   <tt>% </tt><b><span class="c2">newmged Mug.g</span></b><tt>
   BRL-CAD Release 4.5   Graphics Editor (MGED)
       Tue May 20 10:33:44 EDT 1997, Compilation 5378
       jra@vapor.arl.mil:/m/cad/.mged.6d

   Mug.g: No such file or directory
   Create new database (y|n)[n]? </tt><b><span class=
"c2">y</span></b><tt>
   Creating new database "Mug.g"
   Untitled MGED Database (units=mm)
   attach (nu|X|ogl|glx)[nu]? </tt><b><span class=
"c2">ogl</span></b><tt>
   mged&gt; </tt><b><span class=
"c2">title MGED Tutorial Geometry</span></b><tt>
   mged&gt; </tt><b><span class="c2">units in</span></b><tt>
   New editing units = 'in'
   mged&gt; </tt><b><span class=
"c2">in outside.s rcc</span></b><tt>
   Enter X, Y, Z of vertex: </tt><b><span class=
"c2">0 0 0</span></b><tt>
   Enter X, Y, Z of height (H) vector: </tt><b><span class=
"c2">0 0 3.5</span></b><tt>
   Enter radius: </tt><b><span class="c2">1.75</span></b><tt>
   42 vectors in 0.006435 sec
   mged&gt; </tt><b><span class=
"c2">in inside.s rcc 0 0 0.25 0 0 3.5 1.5</span></b><tt>
   42 vectors in 0.006435 sec
   mged&gt; </tt><b><span class=
"c2">in ring.s eto 0 2.5 1.75 1 0 0</span></b><tt>
   Enter X, Y, Z, of vector C: </tt><b><span class=
"c2">.6 0 0</span></b><tt>
   Enter radius of revolution, r: </tt><b><span class=
"c2">1.45</span></b><tt>
   Enter elliptical semi-minor axis, d: </tt><b><span class=
"c2">0.2</span></b><tt>
   2479 vectors in 0.087375 sec
   mged&gt; </tt><b><span class=
"c2">comb cup.c u outside.s - inside.s</span></b><tt>
   mged&gt; </tt><b><span class=
"c2">comb handle.c u ring.s - outside.s</span></b><tt>
   mged&gt; </tt><b><span class=
"c2">r mug.r u cup.c u handle.c</span></b><tt>
   Defaulting item number to 1002
   Creating region id=1001, air=0, los=100, GIFTmaterial=1</tt>
</pre>
  <p>The first step in preparing a new database is to provide a
  title which describes the contents of the database.&nbsp; This is
  an important opportunity to describe the contents and purpose of
  the database.&nbsp; Setting the title is done with the <a href=
  "mged_cmd_index.html#title">title</a> command in MGED.&nbsp;</p>
  <pre>
   <tt>mged&gt; </tt><b><span class=
"c2">Title MGED Tutorial Geometry</span></b>
</pre>
  <p>When the database is first created, the default editing units
  are set to millimeters.&nbsp; For this example, we want to
  specify the dimensions of the object in inches.&nbsp; To arrange
  this, the <a href="mged_cmd_index.html#units">units</a> command</p>
  <pre>
   <tt>mged&gt; </tt><b><span class="c2">units in</span></b>
</pre>
  <p>Now we can create our first solid.&nbsp; There are two
  techniques for creating geometry in MGED.&nbsp; The commands for
  these two techniques are <a href=
  "mged_cmd_index.html#make"><em>make</em></a> and <a href=
  "mged_cmd_index.html#in"><em>in</em></a> (for ``insert'').&nbsp; For
  precision modeling the <em>in</em> command offers the greatest
  control over the definition of the solid.&nbsp; This is the
  approach we will use.&nbsp;</p>
  <p>The ``in'' command can take all of its arguments on the
  command line, or it will prompt you for any missing
  portions.&nbsp; Remembering what parameters need to be specified
  for each solid can be difficult at best.&nbsp; All that you
  really need to enter is the command name.&nbsp; Mged will prompt
  you for the rest of the parameters.&nbsp;</p>
  <p>In the first example above we specify the name of the solid we
  are creating (``outside.s'') and the type of solid to create
  (``rcc''). Then mged prompts for the remaining arguments (vertex,
  height vector, and radius):</p>
  <pre><tt>
   mged&gt; </tt><b><span class=
"c2">in outside.s rcc</span></b><tt>
   Enter X, Y, Z of vertex: </tt><b><span class=
"c2">0 0 0</span></b><tt>
   Enter X, Y, Z of height (H) vector: </tt><b><span class=
"c2">0 0 3.5</span></b><tt>
   Enter radius: </tt><b><span class="c2">1.75</span></b>
</pre>
  <p>For the solid ``inside.s'' we specify all the parameters on
  the command line, so mged does not prompt us for additional
  arguments.&nbsp; In the case of the solid ``ring.s'' we specify
  some, but not all of the parameters, and mged prompts us for the
  missing ones:</p>
  <pre>
<tt>
   mged&gt; </tt><b><span class=
"c2">in inside.s rcc 0 0 0.25 0 0 3.5 1.5</span></b><tt>
   42 vectors in 0.006435 sec
   mged&gt; </tt><b><span class=
"c2">in ring.s eto 0 2.5 1.75 1 0 0</span></b><tt>
   Enter X, Y, Z, of vector C: </tt><b><span class=
"c2">.6 0 0</span></b><tt>
   Enter radius of revolution, r: </tt><b><span class=
"c2">1.45</span></b><tt>
   Enter elliptical semi-minor axis, d: </tt><b><span class=
"c2">0.2</span></b><tt>
   2479 vectors in 0.087375 sec
</tt>
</pre>
  <p>As a minimal example, if we wanted to create a sphere called
  ``ball.s'' we could simply type the ``in'' command and let mged
  prompt us for everything else:</p>
  <pre>
   <tt>mged&gt; </tt><b><span class="c2">in</span></b><tt>
   Enter name of solid:</tt> <b><span class=
"c2">ball.s</span></b><tt>
   Enter solid type: </tt> <b><span class="c2">sph</span></b><tt>
   Enter X, Y, Z of vertex: </tt> <b><span class=
"c2">0 0 0</span></b><tt>
   Enter radius: </tt> <b><span class="c2">3</span></b><tt>
   51 vectors in 0.117187 sec</tt>
</pre>
  <p>The three boolean operators supported are union, subtraction
  and intersection. These operations are denoted by the operators
  <em>u, -</em> and <em>+</em> respectively.&nbsp; Mged uses these
  in a sort of prefix notation.&nbsp; In this notation the union
  operator has higher precedence than either subtraction or
  intersection.&nbsp; Hence the following boolean sequence</p>
  <pre>
        (A union B) subtract C

is written as

        u A - C u B - C
</pre>
  <p>The <em>comb</em> command creates a boolean combination.&nbsp;
  In our example we use this to create the shape of the outside of
  the cup called ``cup.s'' Reading the command above that creates
  cup.c, we note that cup.c is formed from the <em>union</em> of
  the volume defined by the solid ``outside.s'' and the
  <em>subtraction</em> of the volume defined by the solid
  ``inside.s''.&nbsp;</p>
  <p>The <a href="mged_cmd_index.html#r">r</a> command creates a
  ``<a href="brlcad_glossary.html#REGION">region</a>''.&nbsp; It is
  just like creating a <a href=
  "brlcad_glossary.html#COMBINATION">combination</a>, but the
  results are a volume of one logical material type.&nbsp;</p>
  <p>Assigning material properties is done with the <em><a href=
  "mged_cmd_index.html#mater">mater</a></em> or <em><a href=
  "mged_cmd_index.html#shader">shader</a></em> command.&nbsp; Here we
  define which <a href="brlcad_glossary.html#SHADER">shader</a>
  should be used when rendering the object, and the parameters for
  the shader.&nbsp; The simplest shader is the ``<a href=
  "shaders.html#plastic">plastic</a>'' shader which uses a Phong
  lighting model.&nbsp; For our mug this will be fine.&nbsp; We
  specify the plastic shader and set the color to a shade of
  green.&nbsp;</p>
  <pre>
<tt>   mged&gt; </tt><b><span class="c2">mater mug.r</span></b><tt>
   Shader =
   Shader?  ('del' to delete, CR to skip) </tt><b><span class=
"c2">plastic</span></b><tt>
   Color = (No color specified)
   Color R G B (0..255)? ('del' to delete, CR to skip) </tt><b><span class="c2">32 128 32</span></b><tt>
   Inherit = 0:  lower nodes (towards leaves) override
   Inheritance (0|1)? (CR to skip) <b><span class="c2">0</span></b>
</tt>
</pre>The Inheritance option should be left 0.&nbsp; This option
will be discussed later.&nbsp;
  <p>Once we have created our geometry, it would be nice to look at
  the wireframe from a variety of angles.&nbsp; By clicking on the
  button menu box a set of options is displayed.&nbsp; The buttons
  labeled "35,25", "Top", "Right", "Front", and "45,45" offer a set
  of standard views.&nbsp;</p>
  <p>It is possible to raytrace the current view from within
  mged.&nbsp; But to do so we need a place to display the
  image.&nbsp; We start up a framebuffer server (number 1) to
  accommodate this:</p>
  <pre> <tt>
   mged&gt; </tt><b><span class=
"c2">exec fbserv 1 /dev/sgip &amp;</span></b>
</pre>
  <p>This runs the ``fbserv'' program which will maintain a
  framebuffer window for us.&nbsp; Now we are ready to raytrace an
  image.&nbsp; First we'll clear the geometry window of all the
  primitives and combinations and regions we've created.&nbsp; Then
  we display the region we want to raytrace with the ``<a href=
  "mged_cmd_index.html#e">draw</a>'' command.&nbsp; Finally, we'll
  select a nice viewing angle of azimuth 35 elevation 25 with the
  ``<a href="mged_cmd_index.html#ae">ae</a>'' command.&nbsp;</p>
  <pre>
<tt>
   mged&gt; </tt><b><span class="c2">Z</span></b><tt>
   mged&gt; </tt><b><span class="c2">draw mug.r</span></b><tt>
   mged&gt; </tt><b><span class="c2">ae 35 25</span></b>
</pre>Now we are ready to raytrace an image.&nbsp; The ``rt''
command starts the raytracer on the geometry.&nbsp; We must tell it
where we want the pixels displayed with the ``-F'' option, and the
size of the image with the -s option:
  <pre>

<tt>   mged&gt; </tt><b><span class="c2">rt -F:1 -s 512</span></b>
</pre>The rt program prints a variety of information when it runs:
  <pre class="c3">
rt -F:0 -s 512
rt -s50 -M -F:0 -s 512 cup.g mug.r
mged&gt; BRL-CAD Release 4.4   Ray-Tracer
    Thu Jan  5 10:08:14 EST 1995, Compilation 1
    mike@wilson.arl.mil:/vld/src/brlcad/rt

db title:  MGED Tutorial Geometry
initial dynamic memory use=131072.
GETTREE: cpu = 0.001619 sec, elapsed = 0.004842 sec
    parent: 0.0user 0.0sys 0:00real 0% 0i+0d 2100maxrss 0+27pf 0+1csw
  children: 0.0user 0.0sys 0:00real 0% 0i+0d 0maxrss 0+0pf 0+0csw
Additional dynamic memory used=0. bytes

...................Frame     0...................
PREP: cpu = 0.001296 sec, elapsed = 0.003973 sec
    parent: 0.0user 0.0sys 0:00real 0% 0i+0d 2100maxrss 0+7pf 1+0csw
  children: 0.0user 0.0sys 0:00real 0% 0i+0d 0maxrss 0+0pf 0+0csw
Additional dynamic memory used=0. bytes
Tree: 3 solids in 1 regions
Model: X(-45,45), Y(-45,116), Z(-8,97)
View: 35 azimuth, 25 elevation off of front view
Orientation: 0.248097, 0.476591, 0.748097, 0.389435
Eye_pos: 87.6646, 90.5654, 97.5286
Size: 236.164mm
Grid: (0.461258, 0.461258) mm, (512, 512) pixels
Beam: radius=0.230629 mm, divergence=0 mm/1mm
Dynamic scanline buffering
Lighting: Ambient = 40%
  Implicit light 0: (155.394, -35.3438, 49.9036), aimed at (0, 0, -1)
  Implicit light 0: invisible, no shadows, 1000 lumens (83%), halfang=180

SHOT: cpu = 6.66068 sec, elapsed = 7.33342 sec
    parent: 6.6user 0.0sys 0:07real 91% 0i+0d 2100maxrss 0+20pf 0+251csw
  children: 0.0user 0.0sys 0:07real 0% 0i+0d 0maxrss 0+0pf 0+0csw
Additional dynamic memory used=0. bytes
154520 solid/ray intersections: 94456 hits + 60064 miss
pruned 61.1%:  151248 model RPP, 0 dups skipped, 50361 solid RPP
Frame     0:   262144 pixels in       6.66 sec =   39356.94 pixels/sec
Frame     0:   262144 rays   in       6.66 sec =   39356.94 rays/sec (RTFM)
Frame     0:   262144 rays   in       6.66 sec =   39356.94 rays/CPU_sec
Frame     0:   262144 rays   in       7.33 sec =   35746.50 rays/sec (wallclock)

</pre>If all goes well, you will get an image of a green mug on a
black background.&nbsp;<br>
  <div class="c1">
    <a href="mug_green.jpg"><img src="mug_green.gif" alt=
    "green mug"></a>
  </div>
  <p>Now let's improve on our basic cup.&nbsp; The lip of this cup
  looks a little too squared off.&nbsp; To fix this, we'll add a
  rounded top to the lip.&nbsp; To do this we create a circular
  torus solid positioned at exactly the top of the cup.&nbsp; Then
  we can add it to the combination ``cup.c''.</p>
  <pre><tt>
   mged&gt; </tt><b><span class=
"c2">in rim.s tor 0 0 3.5 0 0 1 1.625 0.125</span></b><tt>
   214 vectors in 0.001814 sec
   mged&gt; </tt><b><span class="c2">comb cup.c u rim.s</span></b>
</pre>Now we have a unique condition.&nbsp; The solid rim.s was
added to the list of objects being displayed when it was
created.&nbsp; However, now it is also a part of mug.r (via
cup.c).&nbsp; 
<!-- XXX mged should update the display of combinations when they are changed too -->
   If we raytrace the current view we will have 2 copies of this
  solid.&nbsp; The raytracer will complain that they overlap.&nbsp;
  The best way to fix this is to clear the display, redisplay the
  new, complete object, and then raytrace.&nbsp; The ``<a href=
  "mged_cmd_index.html#Z">Z</a>'' command clears all objects from the
  display. Then we can redisplay the objects we want to raytrace
  with the ``<a href="mged_cmd_index.html#e">draw</a>'' command.
  <pre><tt>
   mged&gt; </tt><b><span class="c2">Z</span></b><tt>
   mged&gt; </tt><b><span class="c2">draw mug.r</span></b>
</pre>Since this is a frequent operation (clear the display list
and draw something new) there is a shortcut:
  <pre><tt>
   mged&gt; </tt><b><span class="c2">B mug.r</span></b>
</pre>The ``<a href="mged_cmd_index.html#B">B</a>'' is not very easy to
remember (one suggested mnemonic is "blast"), but it is quite
useful.
  <p>Now we are ready to raytrace again.</p>
  <pre class="c3"><tt>
   mged&gt; </tt><b><span class="c2">rt -F:1 -s 512</span></b><tt>
   rt -s50 -M -F:1 -s 512 mug.g mug.r
   BRL-CAD Release 4.4   Ray-Tracer
       Thu Jan  5 10:08:14 EST 1995, Compilation 1
       mike@wilson.arl.mil:/vld/src/brlcad/rt

   db title:  MGED Tutorial Geometry
   initial dynamic memory use=131072.
   GETTREE: cpu = 0.001785 sec, elapsed = 0.005385 sec
       parent: 0.0user 0.0sys 0:00real 0% 0i+0d 2152maxrss 0+31pf 0+1csw
     children: 0.0user 0.0sys 0:00real 0% 0i+0d 0maxrss 0+0pf 0+0csw
   Additional dynamic memory used=0. bytes

   ...................Frame     0...................
   PREP: cpu = 0.001468 sec, elapsed = 0.004084 sec
       parent: 0.0user 0.0sys 0:00real 0% 0i+0d 2152maxrss 0+7pf 1+0csw
     children: 0.0user 0.0sys 0:00real 0% 0i+0d 0maxrss 0+0pf 0+0csw
   Additional dynamic memory used=0. bytes
   Tree: 4 solids in 1 regions
   Model: X(-45,45), Y(-45,116), Z(-8,97)
   View: 35 azimuth, 25 elevation off of front view
   Orientation: 0.248097, 0.476591, 0.748097, 0.389435
   Eye_pos: 87.6646, 90.5654, 116.579
   Size: 236.164mm
   Grid: (0.461258, 0.461258) mm, (512, 512) pixels
   Beam: radius=0.230629 mm, divergence=0 mm/1mm
   Dynamic scanline buffering
   Lighting: Ambient = 40%
     Implicit light 0: (155.394, -35.3438, 49.9036), aimed at (0, 0, -1)
     Implicit light 0: invisible, no shadows, 1000 lumens (83%), halfang=180

   SHOT: cpu = 7.26825 sec, elapsed = 7.94901 sec
       parent: 7.2user 0.0sys 0:07real 92% 0i+0d 2152maxrss 0+22pf 1+270csw
     children: 0.0user 0.0sys 0:07real 0% 0i+0d 0maxrss 0+0pf 0+0csw
   Additional dynamic memory used=0. bytes
   170747 solid/ray intersections: 99501 hits + 71246 miss
   pruned 58.3%:  151252 model RPP, 0 dups skipped, 64892 solid RPP
   Frame     0:   262144 pixels in       7.27 sec =   36067.02 pixels/sec
   Frame     0:   262144 rays   in       7.27 sec =   36067.02 rays/sec (RTFM)
   Frame     0:   262144 rays   in       7.27 sec =   36067.02 rays/CPU_sec
   Frame     0:   262144 rays   in       7.95 sec =   32978.18 rays/sec (wallclock)

</tt></pre>
  <div class="c1">
    <a href="rim.jpg"><img src="rim.gif" alt="rounded rim cup"></a>
  </div>
</body>
</html>
